package logic

import (
	"context"
	"gateway/websocket"
	"net/http"

	"gateway/internal/svc"
	"gateway/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type WebsocketLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
	W      http.ResponseWriter
	R      *http.Request
}

func NewWebsocketLogic(ctx context.Context, svcCtx *svc.ServiceContext, req http.ResponseWriter, rep *http.Request) *WebsocketLogic {
	return &WebsocketLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
		W:      req,
		R:      rep,
	}
}

func (l *WebsocketLogic) Websocket(req *types.DeviceReq) error {
	// todo: add your logic here and delete this line
	websocket.Start(l.W, l.R, req.Device)
	return nil
}
